package game.games.gol;

import java.awt.Color;

public class ColorSet
{
    public final static ColorSet DEFAULT     = new ColorSet(Color.GREEN, Color.RED, Color.DARK_GRAY, Color.BLACK);
    public final static ColorSet BLACK_WHITE = new ColorSet(Color.BLACK, Color.DARK_GRAY, Color.LIGHT_GRAY, Color.WHITE);
    
    
    // vars
    private Color isAlive_isSurviving;
    private Color isAlive_notSurviving;
    private Color notAlive_isSurviving;
    private Color notAlive_notSurviving;
    
    public ColorSet(Color isAlive_isSurviving, Color isAlive_notSurviving, Color notAlive_isSurviving, Color notAlive_notSurviving)
    {
        this.isAlive_isSurviving = isAlive_isSurviving;
        this.isAlive_notSurviving = isAlive_notSurviving;
        this.notAlive_isSurviving = notAlive_isSurviving;
        this.notAlive_notSurviving = notAlive_notSurviving;
    }
    
    public Color getColor(boolean isAlive, boolean isSurviving)
    {
        if (isAlive)
        {
            if (isSurviving)
            {
                return isAlive_isSurviving;
            }
            else
            {
                return isAlive_notSurviving;
            }
        }
        else
        {
            if (isSurviving)
            {
                return notAlive_isSurviving;
            }
            else
            {
                return notAlive_notSurviving;
            }
        }
    }

    public static ColorSet getById(String color)
    {
        ColorSet result = DEFAULT;
        if ("0".equals(color) || "default".equals(color))
        {
            result = DEFAULT;
        }
        else if ("1".equals(color) || "black&white".equals(color))
        {
            result = BLACK_WHITE;
        }
        return result;
    }
}
